<!--
 * @Author: jqm123 2289662078@qq.com
 * @Date: 2025-06-10 15:02:14
 * @LastEditors: jqm123 2289662078@qq.com
 * @LastEditTime: 2025-06-25 08:28:04
 * @FilePath: /anxinxiu/src/components/goodsItem.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<script setup>
// 定义 props
const props = defineProps({
  recommend: {
    type: Boolean,
    default: false,
  },
  item: {
    type: Object,
    default: () => {
      return {};
    },
  },
})

// 定义 emits
const emit = defineEmits(['buy'])

// 方法定义
const buy = () => {
  emit("buy", props.item);
}
</script>
<template>
  <div class="goodsItem" :class="{ recommend: recommend }">
    <div class="goodsPic">
      <van-image width="100%" height="100%" :src="item.thumbnail" />
    </div>
    <div class="goods_info">
      <div class="name">{{ item.goodsName }}</div>
      <div class="bottom">
        <div class="price">¥{{ item.price }}</div>
        <div class="btn" @click.stop="buy">抢购</div>
      </div>
    </div>
  </div>
</template>



<style lang="less" scoped>
.goodsItem {
  display: flex;
  align-items: center;
  width: 100%;
  padding-bottom: 8px;
  padding-top: 8px;
  border-bottom: 1px solid #f3f3f3;

  .goodsPic {
    min-width: 57px;
    max-width: 57px;
    height: 55px;
  }

  .goods_info {
    margin-left: 10px;
    flex-grow: 1;

    .name {
      font-size: 13px;
      margin-bottom: 17px;
    }

    .bottom {
      display: flex;
      align-items: center;
      justify-content: space-between;

      .price {
        font-size: 15px;
        color: #c10500;
        font-weight: bold;
      }

      .btn {
        font-size: 13px;
        color: #fff;
        background: #e73353;
        padding: 2px 12px;
        border-radius: 3px;
      }
    }
  }
}

.recommend {
  padding-bottom: 0;
  padding-top: 0;
  border-bottom: unset;
}</style>
